package org.tigris.subversion.svnant.commands;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.tools.ant.Project;
import org.tigris.subversion.svnant.SvnAntUtilities;
import org.tigris.subversion.svnclientadapter.ISVNClientAdapter;
import org.tigris.subversion.svnclientadapter.ISVNProperty;
import org.tigris.subversion.svnclientadapter.SVNClientException;
import org.tigris.subversion.svnclientadapter.SVNUrl;

public class Propget extends SvnCommand
{
  private static final String MSG_CANT_WRITE_PROPERTY = "Can't write property value to file %s";
  private static final String MSG_CANT_GET_PROPERTY = "Can't get property %s";
  private File path;
  private SVNUrl url;
  private String name;
  private String property;
  private File file;

  public void execute()
  {
    ISVNProperty localISVNProperty;
    try
    {
      if (this.path != null)
        localISVNProperty = getClient().propertyGet(this.path, this.name);
      else
        localISVNProperty = getClient().propertyGet(this.url, this.name);
    }
    catch (SVNClientException localSVNClientException)
    {
      throw ex(localSVNClientException, "Can't get property %s", new Object[] { this.name });
    }
    if ((this.property != null) && (localISVNProperty != null))
      getProject().setProperty(this.property, localISVNProperty.getValue());
    if (this.file != null)
    {
      FileOutputStream localFileOutputStream = null;
      try
      {
        localFileOutputStream = new FileOutputStream(this.file);
        if (localISVNProperty != null)
          localFileOutputStream.write(localISVNProperty.getData());
      }
      catch (IOException localIOException)
      {
        throw ex(localIOException, "Can't write property value to file %s", new Object[] { this.file.toString() });
      }
      finally
      {
        SvnAntUtilities.close(localFileOutputStream);
      }
    }
  }

  protected void validateAttributes()
  {
    SvnAntUtilities.attrsNotSet("path, url", true, new Object[] { this.path, this.url });
    SvnAntUtilities.attrNotEmpty("name", this.name);
    SvnAntUtilities.attrsNotSet("property, file", new Object[] { this.property, this.file });
  }

  public void setFile(File paramFile)
  {
    this.file = paramFile;
  }

  public void setPath(File paramFile)
  {
    this.path = paramFile;
  }

  public void setUrl(SVNUrl paramSVNUrl)
  {
    this.url = paramSVNUrl;
  }

  public void setProperty(String paramString)
  {
    this.property = paramString;
  }

  public void setName(String paramString)
  {
    this.name = paramString;
  }
}

/* Location:           C:\Users\Administrator\Desktop\svnant.jar
 * Qualified Name:     org.tigris.subversion.svnant.commands.Propget
 * JD-Core Version:    0.6.0
 */